import React, { useState } from 'react'
import Taro, { FC, useRouter } from '@tarojs/taro'
import { View, Button } from '@tarojs/components'
import { AtTextarea } from 'taro-ui'
import api from '@/services/config/index'
import './index.scss'

const Report: FC = () => {
  const [reportmMsg, setReportmMsg] = useState<string>('')
  const router = useRouter()
  const { shareId } = router.params
  function reportShare() {
    if (!reportmMsg) {
      Taro.showToast({ title: '请输入举报信息', icon: 'none' })
      return
    }
    api['itemSharing/reportShare']({ shareId, description: reportmMsg }).then((_) => {
      Taro.showToast({ title: '举报成功', icon: 'none' })
      setTimeout(() => {
        Taro.navigateBack({ delta: 1 })
      }, 1000)
    })
  }
  return (
    <View className='itemsReport  iphonex-safe-dis'>
      <AtTextarea
        className='itemsReport-txt'
        value={reportmMsg}
        onChange={(value) => {
          setReportmMsg(value)
        }}
        maxLength={100}
        placeholder='请求输入举报信息'
        fixed
        count
        autoFocus
      />

      <Button className='commmon-btn' onClick={reportShare}>
        确定
      </Button>
    </View>
  )
}
export default Report
